<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>角色新增</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/sele.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<script type="text/javascript" src="js/jquery.ztree.core-3.1.js"></script>
<script type="text/javascript" src="js/jquery.ztree.excheck-3.1.js"></script>
<link rel="stylesheet" type="text/css" href="css/zTreeStyle2.css" />
<script> 
(function (config) {
    config['lock'] = true;
    config['fixed'] = true;
    config['okVal'] = 'Ok';
    config['cancelVal'] = 'Cancel';
})(art.dialog.defaults);
</script>
<script type="text/javascript">
var setting = {
		view: {
			selectedMulti: false
		},
		check: {
			enable: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onCheck: onCheck
		}
	};
var zNodes = ${treeData};
var clearFlag = false;
function onCheck(e, treeId, treeNode) {
	count();
	if (clearFlag) {
		clearCheckedOldNodes();
	}
}
function clearCheckedOldNodes() {
	var zTree = $.fn.zTree.getZTreeObj("treeDemo");
	nodes = zTree.getChangeCheckedNodes();
	for (var i=0, l=nodes.length; i<l; i++) {
		nodes[i].checkedOld = nodes[i].checked;
	}
}
function count() {
	var zTree = $.fn.zTree.getZTreeObj("treeDemo");
	checkCount = zTree.getCheckedNodes(true).length;
	$("#func").empty();
	var checkNodes = zTree.getCheckedNodes(true);
	for(var i=0;i<checkNodes.length;i++){
		$("#func").append("<input type='hidden' name='functionId' value='"+checkNodes[i].id+"'/>");
	}
}
function createTree() {
	$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	count();
}

function submitForm() {
	var name=document.getElementById("roleName").value;
	var code=document.getElementById("roleCode").value;
	var flag=true;
	if(name==null || name=="")
	{
		document.getElementById("roleName").focus();
		art.dialog.tips('角色名称不能为空！', 1.5);
		flag=false;
		return;	
	}
	if(code==null || code=="")
	{
		document.getElementById("roleCode").focus();
		art.dialog.tips('角色代码不能为空！', 1.5);
		flag=false;
		return;
	}
	if(flag)
	{
		document.forms[0].submit();
	}
}

$(document).ready(function(){
	var panel = $("#panel").omPanel({
		iconCls : "apple",
		header : true,
		title : '系統功能項',
		collapsed : false,//元件創建後為收起狀態
		collapsible : false //渲染收起與展開按鈕
	});
	createTree();			
	$("#init").bind("change", createTree);
	$("#last").bind("change", createTree);
	//operamasks omTree使用
	/* $("#mytree").omTree({
		dataSource : treed,
		showCheckbox : true,
		onCheck: function(node,event) {
            
        }
	}); */
});
</script>
</head>
<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li>首页</li>
			<li>系统管理</li>
			<li><a href="#"
				onclick="javascript:window.location.href='./adminRole.do?action=list'">
					角色管理</a></li>
			<li>新增角色</li>
		</ul>
	</div>
	<div class="rightinfo">
		<form id="form1" action="./adminRole.do?action=addRole" method="post">

			<ul class="seachform">
				<li><label>角色名称：</label> <input id="roleName" type="text"
					name="roleName" size="10" style="width: 100px; height: 32px;"
					class="scinput" autocomplete="off" /></li>
				<li><label>角色代码：</label> <select id="roleCode" name="roleCode"
					class="form-control" style="width: 230px;">
						<option value="ROLE_ADMIN">超级管理员</option>
						<option value="ROLE_WF_ADMIN">流程管理員</option>
						<option value="ROLE_KPI_BU_USER">異常管理員</option>
						<option value="ROLE_KPI_BU_AUDITOR">異常管理審核主管</option>
						<option value="ROLE_SAFETY_PORTAL">門戶網站管理員</option>
						<option value="ROLE_RES_ADMIN">安防資源管理員</option>
						<option value="ROLE_NORMAL_SIGN_USER">普通簽核人員</option>

						<option value="ROLE_WF_A1.1_APPLY_DEPT_APPLYER">a1.1需求單位表單申請人</option>
						<option value="ROLE_WF_A1.1_APPLY_DEPT_NDA">a1.1需求單位NDA專員</option>
						<option value="ROLE_WF_A1.1_APPLY_DEPT_AUDITOR">a1.1需求單位審核人</option>
						<option value="ROLE_WF_A1.1_FACTORY_PRODUCT_SAFETY_CONFIRMER">a1.1廠區-產品安全處確認主管</option>
						<option value="ROLE_WF_A1.1_FACTORY_MARSTER">a1.1廠區核准權限主管</option>

						<option value="ROLE_WF_A1.2_APPLY_DEPT_APPLYER">a1.2需求單位表單申請人</option>
						<option value="ROLE_WF_A1.2_APPLY_DEPT_NDA">a1.2需求單位NDA專員</option>
						<option value="ROLE_WF_A1.2_APPLY_DEPT_AUDITOR">a1.2需求單位審核人</option>
						<option value="ROLE_WF_A1.2_FACTORY_APPROVED_MARSTER">a1.2廠區核准權限主管</option>

						<option value="ROLE_WF_A1_FACTORY_SMART_MANAGEMENT_DEPT_NDA">a1廠區-智權管理部-NDA專員</option>

						<option value="ROLE_WF_A3_APPLY_DEPT_AUDITOR">a3需求單位審核人</option>
						<option
							value="ROLE_WF_A3_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a3需求單位廠部級主管核準</option>
						<option value="ROLE_WF_A3_PRODUCT_SAFETY_SENDER">a3產品安全處派件人</option>
						<option value="ROLE_WF_A3_PRODUCT_SAFETY_ASSESSOR">a3產品安全處規劃評估人員</option>
						<option value="ROLE_WF_A3_PRODUCT_SAFETY_CONFIRMER">a3產品安全處確認主管</option>
						<option value="ROLE_WF_A3_APPLY_DEPT_APPLYER">a3需求單位表單申請人</option>

						<option value="ROLE_WF_A4_PRODUCT_SAFETY_AUDITOR1">a4產品安全處一級審核主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_AUDITOR2">a4產品安全處二級審核主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_AUDITOR3">a4產品安全處三級審核主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_APPROVED_MARSTER">a4產品安全處核准主管</option>
						<option value="ROLE_WF_A4_PRODUCT_SAFETY_ASSESSOR">a4產品安全處評估作業人員</option>
						<option value="ROLE_WF_A4_APPLY_DEPT_AUDITOR">a4需求單位審核人</option>
						<option
							value="ROLE_WF_A4_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a4需求單位廠部級主管核準</option>
						<option value="ROLE_WF_A4_APPLY_DEPT_APPLYER">a4需求單位表單申請人</option>
						<option value="ROLE_WF_A4_FACTORY_OPERATION_CONTROL1">a4廠區-經管一級簽核人</option>
						<option value="ROLE_WF_A4_FACTORY_OPERATION_CONTROL2">a4廠區-經管二級簽核人</option>
						<option value="ROLE_WF_A4_FACTORY_OPERATION_CONTROL3">a4廠區-經管三級簽核人</option>

						<option value="ROLE_WF_A5_APPLY_DEPT_APPLYER">a5需求單位表單申請人</option>
						<option value="ROLE_WF_A5_APPLY_DEPT_SAFETY_MASKER">a5需求單位安全主管</option>
						<option value="ROLE_WF_A5_APPLY_DEPT_AUDITOR">a5需求單位審核人</option>
						<option
							value="ROLE_WF_A5_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a5需求單位廠部級核準主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_AUDITOR1">a5產品安全處一級審核主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_AUDITOR2">a5產品安全處二級審核主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_AUDITOR3">a5產品安全處三級審核主管</option>
						<option value="ROLE_WF_A5_PRODUCT_SAFETY_APPROVED_MARSTER">a5產品安全處核准主管</option>
						<option value="ROLE_WF_A5_MONITOR_INQUIRY_TASK_PERSON">a5監控調閱作業人員</option>

						<option value="ROLE_WF_A6_PRODUCT_SAFETY_CONFIRMER">a6產品安全處確認主管</option>
						<option value="ROLE_WF_A6_APPLY_DEPT_APPLYER">a6需求單位表單申請人</option>
						<option value="ROLE_WF_A6_APPLY_DEPT_AUDITOR">a6需求單位審核人</option>
						<option
							value="ROLE_WF_A6_APPLY_DEPT_FACTORY_DEPT_APPROVED_MARSTER">a6需求單位廠部級主管核準</option>
						<option value="ROLE_WF_A6_APPLY_DEPT_MANUFACTURE_MARSTER">a6需求單位製造處處級核準主管</option>
						<option value="ROLE_WF_A6_PRODUCT_SAFETY_UPLOSDER">a6產品安全處表單上傳員</option>
				</select></li>
				<li><label>角色描述：</label> <input id="roleDesc" type="text"
					name="description" size="10" style="width: 265px; height: 32px;"
					class="scinput" autocomplete="off" /></li>
			</ul>
			<div id="panel">
				<div id="main">
					<!-- <ul id="mytree"></ul> -->
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
			<div id="func">
				
			</div>
			<ul class="forminfo" style="margin-top: 30px;">
				<li><label>&nbsp;</label> <input name="" type="button"
					id="save" onclick="submitForm();" class="btn" value="确定创建" /> <input
					style="margin-left: 100px;"
					onclick="javascript:document.location.href = './adminRole.do?action=list';"
					type="button" class="cancel" value="取消创建" /></li>
			</ul>
		</form>
	</div>
</body>
<script type="text/javascript">
window.onload=function()
{
	var isAddSuccess = '${isAddSuccess}';
	if(isAddSuccess=="success")
	{
		j.omMessageBox.alert({
	           content:'新增角色成功！',
	           onClose:function(v){
	        	   document.location.href = './adminRole.do?action=list';
	           }
	       });
	}
	else if(isAddSuccess=="error")
	{
		j.omMessageBox.alert({
	           content:'新增角色失败！',
	           onClose:function(v){
	           }
	       });
	}
};
</script>
</html>